#include<stdio.h>
#include<stdlib.h>
struct S
{
	char* data;
	int top;
	int maxsize;
};
typedef struct S* Stack;
Stack CreateStack(int MaxSize);
void push(Stack S, char c);
char pop(Stack S);
int main()
{
	Stack S;
	S = CreateStack(21);
	char a[40];
	char c;
	int i = 0;
	while ((a[i++] = getchar()) != '\n');
	a[i] = '\0';
	i = 0;
	int flag = 1;
	while (a[i] != '\0')
	{
		if (a[i] >= '0' && a[i] <= '9')
		{
			if (flag == 1) {
				printf("%c", a[i]);
			}
			else {
				printf(" %c", a[i]);
				flag = 1;
			}
		}
		else if (a[i] == '.')
		{
			printf("%c", a[i]);
			i++;
			while (a[i] >= '0' && a[i] <= '9')
			{
				printf("%c", a[i]);
				i++;
			}
			i--;
		}
		else if (a[i] == '+')
		{
			if (i == 0);
			else {
				if (S->top != -1 && S->data[S->top] != '(')
				{
					while (S->top != -1 && S->data[S->top] != '(')
					{
						c = pop(S);
						printf(" %c", c);
					}
				}
				push(S, a[i]);
				flag = 0;
			}
		}
		else if (a[i] == '-')
		{
			if (i == 0) { printf("%c", a[i]); }
			else {
				if (S->top != -1 && S->data[S->top] != '(')
				{
					while (S->top != -1 && S->data[S->top] != '(')
					{
						c = pop(S);
						printf(" %c", c);
					}
				}
				push(S, a[i]);
				flag = 0;
			}
		}
		else if (a[i] == '*')
		{
			if (S->top != -1 && (S->data[S->top] == '*' || S->data[S->top] == '/'))
			{
				while (S->top != -1 && (S->data[S->top] == '*' || S->data[S->top] == '/'))
				{
					c = pop(S);
					printf(" %c", c);
				}
			}
			push(S, a[i]);
			flag = 0;
		}
		else if (a[i] == '/')
		{
			if (S->top != -1 && (S->data[S->top] == '*' || S->data[S->top] == '/'))
			{
				while (S->top != -1 && (S->data[S->top] == '*' || S->data[S->top] == '/'))
				{
					c = pop(S);
					printf(" %c", c);
				}
			}
			push(S, a[i]);
			flag = 0;
		}
		else if (a[i] == '(')
		{
			push(S, a[i]);
			if (a[i + 1] == '+') { i++; }
			else if (a[i + 1] == '-')
			{
				printf(" %c", a[i + 1]); flag = 1; i++;
			}
		}
		else if (a[i] == ')')
		{
			while (S->data[S->top] != '(')
			{
				c = pop(S);
				printf(" %c", c);
			}
			c = pop(S);
		}
		i++;
	}
	if (S->top != -1)
	{
		while (S->top != -1)
		{
			c = pop(S);
			printf(" %c", c);
		}
	}
	return 0;
}
Stack CreateStack(int MaxSize)
{
	Stack S = (Stack)malloc(sizeof(struct S));
	S->data = (char*)malloc(MaxSize * sizeof(char));
	S->top = -1;
	S->maxsize = MaxSize;
	return S;
}
void push(Stack S, char c)
{
	S->top++;
	S->data[S->top] = c;
}
char pop(Stack S)
{
	return S->data[S->top--];
}